﻿/* 
 * This file is part of marvellous-components project.
 * 
 * The marvellous-components is free software: you can redistribute it 
 * and/or modify it under the terms of the GNU General Public License 
 * version 3 as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace marvellous_components.MagnificentTimeReportDataGridView
{
    /// <summary>
    /// Single row used in MagnificentTimeReportDataGridView.
    /// 
    /// This class is partially immutable. This means that basic data can not be modified.
    /// Setter is available only for activeField.
    /// </summary>
    public class RowData
    {
        private DateTime date = DateTime.Now;
        private WorkTime time;
        private string description1, description2, description3;
        private int activeField = 0;
        private bool modified = false;

        private RowData(RowData rd)
        {
            this.date = rd.date;
            this.time = rd.time;
            this.description1 = rd.description1;
            this.description2 = rd.description2;
            this.description3 = rd.description3;
            this.activeField = rd.activeField;
            modified = true;
        }

        public RowData(int workTimeHours, int workTimeMinutes)
        {
            this.time = new WorkTime(workTimeHours, workTimeMinutes);
        }

        public RowData(DateTime date, int workTimeHours, int workTimeMinutes, string description1, string description2, string description3)
        {
            this.date = date;
            this.time = new WorkTime(workTimeHours, workTimeMinutes);
            this.description1 = description1;
            this.description2 = description2;
            this.description3 = description3;
        }

        public DateTime Date
        {
            get { return date; }
        }

        public RowData changeDate(DateTime date)
        {
            RowData result = new RowData(this);
            result.date = date;
            return result;
        }

        public WorkTime Time
        {
            get { return time; }
        }

        public RowData changeTime(WorkTime time)
        {
            RowData result = new RowData(this);
            result.time = time;
            return result;
        }

        public string Description1
        {
            get { return description1; }
        }

        public RowData changeDesc1(string desc1)
        {
            RowData result = new RowData(this);
            result.description1 = desc1;
            return result;
        }

        public string Description2
        {
            get { return description2; }
        }

        public RowData changeDesc2(string desc2)
        {
            RowData result = new RowData(this);
            result.description2 = desc2;
            return result;
        }

        public string Description3
        {
            get { return description3; }
        }

        public RowData changeDesc3(string desc3)
        {
            RowData result = new RowData(this);
            result.description3 = desc3;
            return result;
        }

        public int ActiveField
        {
            get { return activeField; }
            set { activeField = value; }
        }

        public bool Modified
        {
            get { return modified; }
        }

        public object[] getDataForRow()
        {
            return new object[] { date, time, description1, description2, description3, this };
        }
    }
}
